/**
 * 
 */
package com.vision.core.sv.db;

import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean;

/**
 * TODO Just a patch. Find the proper way of getting hold of the autowired
 * SessionFactory instance.
 * 
 * @author Mark
 */
public class CustomSessionFactoryBean extends AnnotationSessionFactoryBean {

	// XXX Used to keep a reference of the autowired SessionFactory instance.
	private static SessionFactory factory = null;
	
	public static SessionFactory getFactory() {
		return factory;
	}
	
	@Override
	public SessionFactory buildSessionFactory() throws Exception {
		if (factory == null) {
			factory = super.buildSessionFactory();
		}
		return factory;
	}

}
